/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package core.log;

import java.io.File;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 *
 * @author MartinLe
 */
public final class Monitor {

    private final static String PATH = "conf" + File.separator + "log4j.properties";
    private final static Logger LOGGER;
    private final static Logger ERROR;
    private final static Logger ACCESS_LOG;

    static {
        try {
            PropertyConfigurator.configureAndWatch(PATH);
            LOGGER = Logger.getLogger("ibig.server");
            ERROR = Logger.getLogger("ibig.error");
            ACCESS_LOG = Logger.getLogger("access");
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }

    /**
     * Write error to log.
     *
     * @param message Message.
     */
    public static void error(final String message) {
        ERROR.error(message);
    }

    /**
     * Write error to log.
     *
     * @param message Message
     * @param exception Exception
     */
    public static void error(final String message, final Throwable exception) {
        ERROR.error(message, exception);
    }

    /**
     * Write an information to log.
     *
     * @param message Message information.
     */
    public static void infor(final String message) {
        LOGGER.info(message);
    }

    /**
     * Write an information to log.
     *
     * @param message Message information.
     */
    public static void accessInfor(final String message) {
        ACCESS_LOG.info(message);
    }

    /**
     * Write debug message to log.
     *
     * @param message Debug message.
     */
    public static void debug(final String message) {
        LOGGER.debug(message);
    }

    /**
     * Write debug message to log.
     *
     * @param message Debug message.
     * @param exception Exception.
     */
    public static void debug(final String message, final Throwable exception) {
        LOGGER.debug(message, exception);
    }

    /**
     * Write a warning message to log.
     *
     * @param message Warning message.
     */
    public static void warn(final String message) {
        LOGGER.warn(message);
    }

    /**
     * Write a warning message to log.
     *
     * @param message Warning message.
     * @param exception Exception.
     */
    public static void warn(final String message, final Throwable exception) {
        LOGGER.warn(message, exception);
    }
}
